package com.huika.dealontop.views;

import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;

import com.huika.dealontop.R;
import com.huika.dealontop.config.Constants;
import com.huika.dealontop.control.base.BaseAct;
import com.huika.dealontop.control.main.MainActivity;

/**
 * 通用底部导航栏
 * Created by zhouweiyong on 2015/11/13.
 */
public class CommonNavigation implements View.OnClickListener {
    private BaseAct mBaseAct;
    private LinearLayout index_navigation;
    private LinearLayout nearby_navigation;
    private LinearLayout timelimit_navigation;
    private LinearLayout myinfo_navigation;

    public CommonNavigation(BaseAct mBaseAct) {
        this.mBaseAct = mBaseAct;
        init();
    }

    private void init() {
        index_navigation = (LinearLayout) mBaseAct.findViewById(R.id.index_navigation);
        nearby_navigation = (LinearLayout) mBaseAct.findViewById(R.id.nearby_navigation);
        timelimit_navigation = (LinearLayout) mBaseAct.findViewById(R.id.timelimit_navigation);
        myinfo_navigation = (LinearLayout) mBaseAct.findViewById(R.id.myinfo_navigation);

    }

    public void setListener() {
        index_navigation.setOnClickListener(this);
        nearby_navigation.setOnClickListener(this);
        timelimit_navigation.setOnClickListener(this);
        myinfo_navigation.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent(mBaseAct, MainActivity.class);
        switch (view.getId()) {
            case R.id.index_navigation:
                intent.putExtra(Constants.NAVIGATION_FLAG, 0);
                break;
            case R.id.nearby_navigation:
                intent.putExtra(Constants.NAVIGATION_FLAG, 1);
                break;
            case R.id.timelimit_navigation:
                intent.putExtra(Constants.NAVIGATION_FLAG, 2);
                break;
            case R.id.myinfo_navigation:
                intent.putExtra(Constants.NAVIGATION_FLAG, 3);
                break;
        }
        mBaseAct.showActivity(mBaseAct, intent);
        mBaseAct.finish();
    }
}
